<template>
  <!-- 忘记密码部分页面公共头部 -->
  <div class="pwd-container">
    <h2>忘记密码</h2>
    <!-- 步骤条 -->
    <div class="pwd-bar clearfix">
      <div class="bar one bar-color"></div>
      <div :class="step !== 'one' ? 'bar two bar-color' : 'bar two'"></div>
      <div :class="step === 'three' ? 'bar three bar-color' : 'bar three'"></div>
    </div>
    <div class="pwd-step">
      <span :class="step === 'one' ? 'span-bold' : ''">第一步：验证身份</span>
      <span :class="step === 'two' ? 'span-bold' : ''">第二步：设置新密码</span>
      <span :class="step === 'three' ? 'span-bold' : ''">第三步：设置成功</span>
    </div>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'Password',
  data() {
    return {
      step: 'one'
    }
  },
  methods: {
    changeStep(step) {
      this.step = step
    }
  },
  // 使用事件总线，修改进度条样式
  mounted() {
    this.$bus.$on('changeStep', this.changeStep)
  },
  beforeDestroy() {
    this.$bus.$off('changeStep') // 用 $off去解绑当前组件所用到的事件，不要在事件总线 $bus中占事件命名位置
  }
}
</script>

<style lang='less' scoped>
.pwd-container {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 15px 25px 20px;
  border-radius: 6px;
  width: 621px;
  background-color: #fff;

  h2 {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    text-align: center;
    margin-bottom: 15px;
  }
  
  .pwd-bar {
    width: 513px;
    margin: 0 auto;
    position: relative;
    

    .bar {
      border: 3px solid #fff;
      height: 10px;
      border-radius: 5px;
      background-color: #C9D0DD;
      position: absolute;
    }
    
    .one {
      width: 171px;
      z-index: 3;
    }

    .two {
      width: 342px;
      z-index: 2;
    }

    .three {
      width: 513px;
      z-index: 1;
    }

    .bar-color {
      background-color: #0047AE;
    }
  }

  .pwd-step {
    width: 513px;
    margin: 15px auto;
    display: flex;

    span {
      flex: 1;
      text-align: center;
      line-height: 21px;
      font-size: 16px;
      color: #333;
    }

    .span-bold {
      font-weight: bold;
    }
  }
}
</style>